﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="ActionWithSomeFailingsOnEntity2.cs" company="Collaboris Ltd.">
//   Copyright (c) Collaboris Ltd. All rights Reserved.
// </copyright>
// <summary>
//   Defines the ActionWithSomeFailingsOnEntity2 type.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace Collaboris.Saf.Tests.Support.Actions
{
    using System;
    using System.Collections.Generic;

    using Collaboris.Saf.Engine;
    using Collaboris.Saf.Tests.Support.Entities;

    public class ActionWithSomeFailingsOnEntity2 : ActionBase<Person>
    {

        public ActionWithSomeFailingsOnEntity2() { }

        SafContext safContext;

        protected override ProcessStatus  DoAction(SafContext context, Person person)
        {
            if (person.Surname == "Esperanca")
                throw new Exception("Test - Esp");

            this.safContext = context;
            string x = person.Forename;

            List<Person> peopleList = new List<Person>();
            peopleList.Add(person);

            this.safContext.ActionProperties.Add("People", peopleList, true);
            return ProcessStatus.Success;

        }


        protected override ProcessStatus UndoAction(SafContext context, Person person)
        {
            if (person.Surname == "Jones")
                throw new Exception("Test - Jon");

            this.safContext = context;
            string x = person.Forename;

            List<Person> peopleList = new List<Person>();
            peopleList.Add(person);

            this.safContext.ActionProperties.Add("People", peopleList, true);
            return ProcessStatus.Success;
        }
    }
}